//:C07:exec_7_7.c
#include <stdio.h>
#define R 3
#define C 3

int main(void)
{
    int arr[R][C] = {0};
    int currow = 0;
    int curcol = C / 2;
    arr[0][curcol] = 1;
    int i, j;
    for(i = 2; i <= R * C; i++)
    {
        if(arr[(currow - 1 + R) % R][(curcol + 1) % C] != 0)
        {
            currow = (currow + 1) % R;
        }
        else
        {
            currow = (currow - 1 + R) % R;
            curcol = (curcol + 1) % C;
        }
        arr[currow][curcol] = i;
    }

    for(i = 0; i < R; i++)
    {
        for(j = 0; j < C; j++)
        {
            printf("%-4d", arr[i][j]);
        }
        printf("\n");
    }
    
}
#undef R
#undef C